<?php

  $aux = explode ( '|', isset($_GET['id']) ? $_GET['id'] : '' );
  $ContractUid = str_replace ( '"', '', $aux[0] );

  require_once ( PATH_PLUGINS . 'hr' . PATH_SEP . 'class.hr.php');
  $pluginObj = new hrClass ();

  require_once ( "classes/model/HrContracts.php" );
  //if exists the row in the database propel will update it, otherwise will insert.
  $tr = HrContractsPeer::retrieveByPK( $ContractUid  );

  if ( ( is_object ( $tr ) &&  get_class ($tr) == 'HrContracts' ) ) { 
     $fields['CONTRACT_UID'] = $tr->getContractUid();
     $fields['JOB_ID'] = $tr->getJobId();
     $fields['TYPECONTRACT_ID'] = $tr->getTypecontractId();
     $fields['CONTRACTLENGTH_ID'] = $tr->getContractlengthId();
     $fields['STARTDATE'] = $tr->getStartdate();
     $fields['ENDDATE'] = $tr->getEnddate();
     $fields['ACTIVE'] = $tr->getActive();
  }
  else
    $fields = array();

  $G_MAIN_MENU = 'processmaker';
  $G_SUB_MENU = 'hr/menuhrEmployee';
  $G_ID_MENU_SELECTED = 'ID_HR_EMP';
  $G_ID_SUB_MENU_SELECTED = 'ID_HR_JOBS';


  $G_PUBLISH = new Publisher;
  $G_PUBLISH->AddContent('xmlform', 'xmlform', 'hr/hrContractsEdit', '', $fields, 'hrContractsSave' );
  G::RenderPage('publish', 'blank');
?>